package Command;

import java.util.ArrayList;

import Server.Command;
import Server.cmdArguments;

public class CommitCommand implements Command{
	private cmdArguments args;
	
	public CommitCommand(){}
	
	@Override
	public String execute() {	
		String result = "There was nothing on the queue";
		if(args.bst.getSize() != 0){		

			ArrayList<Integer> actionList = args.bst.getSeqList();
			args.da.insert(actionList);
			args.bst.clear();
			result = "Every insert has been added to the database queue, " + actionList.size() + " entries.";
		}	
		return result;	
	}

	@Override
	public String undo() {				
		return "There was nothing that could be undone";
	}

	@Override
	public void setArgs(cmdArguments args) {
		this.args = args;
	}	
}